<!doctype html>
<html>

<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
    <meta http-equiv="Expires" content="0" />
</head>
<style type="text/css">
    html,
    body {
        height: 100%;
        margin: 0;
        padding: 0;
        border: 0;
        background-color: #4C4B4B;
    }

    /* .plugin {
        width: 300px;
        height: 200px;
    } */
</style>

<body>
    <div id="divPlugin" class="plugin" style="width: 100%;"></div>
</body>
<script src="../haikang/jquery-3.3.1.min.js"></script>
<script src="../haikang/encryption/AES.js"></script>
<script src="../haikang/encryption/cryptico.min.js"></script>
<script src="../haikang/encryption/crypto-3.1.2.min.js"></script>
<script id="videonode" src="../haikang/webVideoCtrl.js"></script>
<script>
    var g_iWndIndex
    $(function () {
        var iWidth = document.getElementById('divPlugin').clientWidth.toFixed(0)
        document.getElementById('divPlugin').style.position = 'absolute'
        document.getElementById('divPlugin').style.height = '100%'
        var iHeight = document.getElementById('divPlugin').clientHeight.toFixed(0)
        // if (!existKey('over')) {
        //     var iHeight = (400 * (iWidth / 600)).toFixed(0)
        // } else {
        //     document.getElementById('divPlugin').style.position = 'absolute'
        //     document.getElementById('divPlugin').style.height = '100%'
        //     var iHeight = document.getElementById('divPlugin').clientHeight.toFixed(0)
        // }
        var oPlugin = {
            iWidth: iWidth, // plugin width 600
            iHeight: iHeight, // plugin height 400
        }
        // console.log(oPlugin)
        document.getElementById('divPlugin').style.width = iWidth + 'px'
        document.getElementById('divPlugin').style.height = iHeight + 'px'
        var iWndowType = existKey("showScreen") ? existKey("showScreen") : 1
        var g_iWndIndex = 0;

        WebVideoCtrl.I_InitPlugin(oPlugin.iWidth, oPlugin.iHeight, {
            bWndFull: true,
            iWndowType: iWndowType,
            cbSelWnd: function (xmlDoc) {
                g_iWndIndex = parseInt($(xmlDoc).find('SelectWnd').eq(0).text(), 10)
                // console.log(g_iWndIndex)

                window.parent.postMessage(g_iWndIndex, '*');
            },
            cbInitPluginComplete: function () {
                WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin");
            },
        });

        $("#divPlugin").on('dblclick', '.draw-window', function () {
            window.parent.postMessage('dblclick_' + $(this).parents("div").index(), '*');
        })

        // document.addEventListener('dblclick', onDocumenDblClick);
    });

    /* 双击全屏 */
    // function onDocumenDblClick(event) {
    //     console.log("鼠标双击");
    //     WebVideoCtrl.I_FullScreen(true);
    // }

    function existKey(key) {
        //1、url截取?之后的字符串(不包含?)
        var pathSearch = window.location.search.substr(1);
        var result = [];
        //2、以&为界截取参数键值对
        var paramItems = pathSearch.split("&");
        // console.log(paramItems);
        // 3、将键值对形式的参数存入数组
        for (var i = 0; i < paramItems.length; i++) {
            var paramKey = paramItems[i].split("=")[0];
            var paramValue = paramItems[i].split("=")[1];
            result.push({
                key: paramKey,
                value: paramValue
            });
        }
        // 4、遍历key值
        for (var j = 0; j < result.length; j++) {
            if (result[j].key === key) {
                // console.log(key);
                return result[j].value;
            }
        }
        return false;
    }
</script>

</html>